﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAL;
using Model;

namespace BLL
{
	/// <summary>
    /// EmpoloyeeBLL
	/// </summary>
	public partial class EmployeeBLL
	{
        private readonly EmployeeDAL dal = new EmployeeDAL();
        public EmployeeBLL()
        {
        }

		/// <summary>
		/// 增加一条数据
		/// </summary>
        public int? Insert(EmployeeModel model)
		{
			return dal.Insert(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public int Update(EmployeeModel model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public int Delete(string Id)
		{
			
			return dal.Delete(Id);
		}		

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public EmployeeModel Get(string Id)
		{
			
			return dal.Get(Id);
		}

        /// <summary>
        /// 得到一个对象实体根据员工编码
        /// </summary>
        public EmployeeModel GetModelByEmployeeNo(string EmployeeNo)
        {

            return dal.GetModelByEmployeeNo(EmployeeNo);
        }

        /// <summary>
        /// 根据Id和编码查询
        /// </summary>
        /// <param name="EmployeeNo"></param>
        /// <returns></returns>
        public int IsExistByIdAndEmployeeNo(string Id, string EmployeeNo)
        {
            return dal.IsExistByIdAndEmployeeNo(Id,EmployeeNo);
        }

        /// <summary>
        /// 根据编码查询
        /// </summary>
        /// <param name="EmployeeNo"></param>
        /// <returns></returns>
        public int IsExistByEmployeeNo(string EmployeeNo)
        {
            return dal.IsExistByEmployeeNo(EmployeeNo);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public IEnumerable<EmployeeModel> GetModelListByNoAndName(string employyeeNo, string employyeeName)
        {
            IEnumerable<EmployeeModel> ds= dal.GetModelListByNoAndName(employyeeNo, employyeeName);
            return ds;
        }

		/// <summary>
		/// 获得数据列表
		/// </summary>
        public List<EmployeeModel> DataTableToList(DataTable dt)
		{
            List<EmployeeModel> modelList = new List<EmployeeModel>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
                EmployeeModel model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = dal.DataRowToModel(dt.Rows[n]);
					if (model != null)
					{
						modelList.Add(model);
					}
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
        public IEnumerable<EmployeeModel> GetList()
		{
			return dal.GetList();
		}

	}
}


